package Ske

import (
	"log"
	"os"
	"io/ioutil"
	"encoding/json"

)
type ConfigGloabl struct {
	Host string `json:"host"`
	Password string `json:"password"`
	User  string `json:"user"`
}
var gGlobalConf *ConfigGloabl

func init()  {
	gGlobalConf = new(ConfigGloabl)
}

func InitConfig()  {
	file,err := os.Open("config.json")
	if err != nil{
		log.Println(err.Error())
		buf,e := json.Marshal(gGlobalConf)
		if e!=nil{
			log.Println(e.Error())
		}
		ioutil.WriteFile("config.json",buf,os.ModePerm)
	}
	ret,err := ioutil.ReadAll(file)
	err = json.Unmarshal(ret,gGlobalConf)
	if err != nil{
		log.Println(err.Error())
	}
	file.Close()
}